//类成员函数对递增运算符重载
#include <iostream>
using namespace std;
class Person{
public:
    int x,y;
    Person(int x=0,int y=0){
        this->x=x;
        this->y=y;
    }
    //前置递增的重载--返回值是引用是为了在链式编程时对一个变量进行操作
    Person& operator++(){
        this->x++;
        this->y++;
        return *this;
    }
    //后置递增的重载--参数int是占位参数，可以用于区分前置和后置递增
    //后置递增返回值，前置递增返回引用
    Person operator++(int){
        Person tmp=*this;
        this->x++;
        this->y++;
        return tmp;
    }
};
//左移运算符的重载
ostream& operator<<(ostream &out,Person p){
    cout<<p.x<<" "<<p.y<<" ";
    return out;
}
int main()
{
    Person p(0,1);
    cout<<++p<<endl;
    cout<<p<<endl;
    cout<<p++<<endl;
    cout<<p<<endl;
    return 0;
}